import { getCityApi } from "../../utils/api";
const cityModule = {
  state: {
    city: '杭州',//主页城市选择
    cityId: '330100',
    citylist: [],//城市列表
  },
  mutations: {
    // 点击城市改变
    city(state, payload) {
      state.city = payload.name;
      state.cityId = payload.cityId;
    },
    // 获取城市列表
    citylist(state, payload) {
      state.citylist = payload.result;
    },
  },
  actions: {
    // 获得城市列表
    async citylistAsc({ commit }) {
      const res = await getCityApi();
      commit("citylist", res);
    },
  }
}
export default cityModule;